﻿using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using MineGoogleTranslator.Core;

namespace MineGoogleTranslator.Service
{
	/// <summary>
	/// Summary description for Translator
	/// </summary>
	[WebService(Namespace = "http://www.codeplex.com/mgt/")]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	[ToolboxItem(false)]
	public class Translator : System.Web.Services.WebService
	{

		// Commented just to show how can be implemented.
		//[WebMethod]
		public String Translate(LanguagePair pairLanguage, string text)
		{
			return MineGoogleTranslator.Core.Translator.Translate(pairLanguage, text);
		}

		// Commented just to show how can be implemented.
		//[WebMethod]
		public String Translate(Language from, Language to, string text)
		{
			return Translate(new LanguagePair(from, to), text);
		}

		[WebMethod]
		public String Translate(string from, string to, string text)
		{
			Language fromLanguage = (Language)Enum.Parse(typeof(Language), from);
			Language toLanguage = (Language)Enum.Parse(typeof(Language), to);
			return Translate(fromLanguage, toLanguage, text);
		}
	}
}
